<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <!-- 修饰符submit.prevent  禁止提交了 -->
    <!-- 修饰符keydown.enter  按下enter键触发fn2 -->
    <form id="form1" action="index.html" method="get" @submit.prevent='fn' @keydown.enter='fn2'>
        <input type="text">
        <input type="submit" value="提交">

    </form>
</body>

<script src="./node_modules/vue/dist/vue.js"></script>
<!-- 可适用异步 -->
<script>
    new Vue({
        el: '#form1',
        data: () => {
            return {
                a: 0
            } 
        },
        methods: {
            fn(){
                alert('提交了')
            }
        }
    })
</script>


</html>